$(function() {
    $("#contractTable").bootstrapTable('destroy').bootstrapTable({
        url : window.portAddress + "/contract/contractList",
        dataType : "json",
        method : 'get',
        striped: true,  //行间隔色
        cache : false,  //禁用缓存
        pageNumber: 1,  //初始化加载第一页
        pagination: true,//是否分页
        sidePagination: "client",//前端分页
        pageSize: 5,//单页记录数
        pageList: [5, 10, 15],//可选择单页记录数
        clickToSelect : true,
        theadClasses: "thead-pink",
        queryParams: function (params) {
            //向服务器传递的参数
            return {
               /* option : $("#search_option option:selected").val(),*/
                contractNumber : $("#contractNumber").val(),
                buyCurrency : $("#buyCurrency").val(),
                sellCurrency : $("#sellCurrency").val(),
                settlementDate : $("#settlementDate").val(),

            };
        },
        responseHandler : function(res) {
            return res.data;
        },
        columns : [
            {
                title : "客户号",
                field : "customerNo",
                align : "center",

            },
            {
                title : "客户名",
                field : "customerName",
                align : "center",

            },
            {
                title : "预定汇率",
                field : "acceptedBooKRate",
                align : "center",
            },
            {
                title : "标准汇率",
                field : "costRate",
                align : "center",
            },
            {
                title : "买入货币",
                field : "buyCurrency",
                align : "center",
            },
            {
                title : "卖出货币",
                field : "sellCurrency",
                align : "center",
            },
            {
                title : "结算日期",
                field : "settlementDate",
                align : "center",
            },
            {
                title : "状态",
                field : "status",
                align : "center",
            }

        ]
    });

    $("#search").click(function() {
        $.ajax({
            url : window.portAddress + "/contract/contractList",
            type : "post",
            data : {
                contractNumber : $("#contractNumber").val(),
                buyCurrency : $("#buyCurrency").val(),
                sellCurrency : $("#sellCurrency").val(),
                settlementDate : $("#settlementDate").val(),
            },
            dataType : "json",
            success : function(data) {
                if (data.state === '000000') {
                    toastr.success("查询数据成功");
                }else {
                    toastr.error(data.message);
                }
                $("#contractTable").bootstrapTable("refresh");
            }
        })
    });


})
